package com.grape;

import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Controller;

import com.grape.utlis.SmsUtils;


@Controller
public class QueueConsumer implements MessageListener{

	@Override
	public void onMessage(Message message) {
		MapMessage tm = (MapMessage) message;
		
		try {
			String telephone = tm.getString("telephone");
			String msg = tm.getString("msg");
			
			System.out.println(telephone+msg);
			
			// 发短信
			String result = SmsUtils.sendSmsByHTTP(telephone, msg);
			// String result = "";
			
			// 结果
			if (result.startsWith("-")) {
				System.out.println("短信发送失败");
			}
			
			
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
}
